﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MongoDB.Driver;
using TransCode.Entitys;

namespace TransCode.Logic
{
    public class ObjectLogic
    {
        MongoDatabase db = MongoDbHelper.DbInstance();

        public List<TargetObject> ObjectList()
        {
            List<TargetObject> result = new List<TargetObject>();

            return db.GetCollection<TargetObject>("TargetObject").FindAll().ToList();
        }

        public void Save(TargetObject entity)
        {
            db.GetCollection<TargetObject>("TargetObject").Save(entity);
        }

        public void Delete(TargetObject entity)
        {
            if (entity != null)
            {
                var query = new QueryDocument("_id", entity.Id);
                db.GetCollection<TargetObject>("TargetObject").Remove(query);
            }
        }
    }
}
